﻿using System;
using System.Xml;
using System.Xml.Serialization;
using rlTodayMakeSkin.Project.Attributes;
using rlTodayMakeSkin.Project.XmlElement.XmlSubElements;
using rlTodayMakeSkin.Project;
using System.Drawing;
using System.Collections.Generic;


namespace rlTodayMakeSkin.Project.XmlElement
{
    /// <summary>
    /// represents an AppName xml elment in skin.xml file
    /// </summary>

    public class rlAppName : ContainerSubElements
    {
        
        private int intAppNumber = 0;        
        private string align;
        private Color colore;
        

        public rlAppName(XmlNode n, rlTodayProject p)
            : base(n, p)
        {
            if (listaAtt["alignment"] != null) align = listaAtt["alignment"].Value;
            if (listaAtt["appnumber"] != null) intAppNumber = int.Parse(listaAtt["appnumber"].Value);
            if(listaAtt["color"] != null) colore = GetColorFromRGB(listaAtt["color"].Value);
            strNome = "AppName";
        }

        public rlAppName(rlTodayProject p)
            : base(p)
        {
            //init name control
            strNome = "AppName";
        }

        public rlAppName() { }

        /// <summary>
        /// Gets, sets appnumber attribute for this element
        /// </summary>
        [PropertyDescription("Gets, sets appnumber attribute for this element")]
        [XmlAttribute("appnumber")]
        public int AppNumber
        {
            get { return intAppNumber; }
            set { intAppNumber = value; }
        }

        /// <summary>
        /// Gets, sets alignment attribute for this element
        /// </summary>
        [PropertyDescription("Gets, sets alignment attribute for this element")]
        [XmlAttribute("alignment")]
        public string Alignment
        {
            get { return align; }
            set {
                if (!value.Equals(rlTodayMakeSkin.Project.XmlElement.Alignment.CENTER) ||
                   !value.Equals(rlTodayMakeSkin.Project.XmlElement.Alignment.LEFT) ||
                   !value.Equals(rlTodayMakeSkin.Project.XmlElement.Alignment.RIGHT)
                   )
                    throw new Exception("Only permitted arguments are value of costants in IAligment interface");
                align = value; 
            }
        }


        /// <summary>
        /// Color property for this element
        /// </summary>
        [PropertyDescription("Color property for this element", PropertyTypes.COLOR)]
        [XmlIgnore()]
        public Color ColorElement
        {
            get { return colore; }
            set { colore = value;}
        }


        /// <summary>
        /// Gets the color attribute value for this element
        /// </summary>
        [XmlAttribute("color")]
        [PropertyDescription("Gets the color attribute value for this element", ReadOnlyProperty=true)]
        public string RGBColor
        {
            get { return
                GetRGBFromColor(colore);
            }
        }

        public override void DrawElement(Graphics g)
        {
            DrawImage(g,"AppNameBig.png");
        }

        /******************
         PRIVATE MEMBERS
         *****************/


    }
}
